<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>mtlb_diff</title>
  </head>
  <body bgcolor="#FFFFFF">
    <center>M2SCI function</center>
    <div align="right">Last update : 07/04/2004</div>
    <p>
      <b>mtlb_diff</b> - Matlab diff emulation function</p>
    <h3>
      <font color="blue">Description</font>
    </h3>
    <p>Matlab and Scilab <tt>
        <b>diff</b>
      </tt> behave differently in some particular cases:</p>
    <dl>
      <dd>
        <b></b>
        <dd>
          <li>
            <b>
              <font color="maroon"></font>
            </b>
        With two input parameters: Scilab <tt>
              <b>diff</b>
            </tt> considers all values of first input as a vector
	what Matlab does not.
        </li>
          <li>
            <b>
              <font color="maroon"></font>
            </b>
        With three input parameters: If dimension of first input along dimension given by third parameter
	reaches 1 before n interations
	have been made,Matlab switches to next non-singleton dimension what Scilab does not.
        </li>
        </dd>
      </dd>
    </dl>
    <p>
    The function <tt>
        <b>mtlb_diff(A[,n[,dim]])</b>
      </tt> is used by
    <tt>
        <b>mfile2sci</b>
      </tt> to replace <tt>
        <b>diff(A[,n[,dim]])</b>
      </tt> when it was not
    possible to know what were the inputs while porting Matlab code to Scilab. This function will
    determine the correct semantic at run time. If you want to have a
    more efficient code it is possible to replace <tt>
        <b>mtlb_diff</b>
      </tt> calls:
    </p>
    <dl>
      <dd>
        <b></b>
        <dd>
          <li>
            <b>
              <font color="maroon"></font>
            </b>
        With two inputs, if <tt>
              <b>A</b>
            </tt> is a scalar or a vector
        <tt>
              <b>mtlb_diff(A,n)</b>
            </tt> may be replaced by <tt>
              <b>diff(A,n)</b>
            </tt>
          </li>
          <li>
            <b>
              <font color="maroon"></font>
            </b>
        With three inputs, if size of A along dimension given by <tt>
              <b>dim</b>
            </tt> can not reach 1
        <tt>
              <b>mtlb_diff(A,n,dim)</b>
            </tt> may be replaced by <tt>
              <b>diff(A,n,dim)</b>
            </tt>
          </li>
        </dd>
      </dd>
    </dl>
    <p>Caution: <tt>
        <b>mtlb_diff</b>
      </tt> has not to be used for hand coded functions.</p>
    <h3>
      <font color="blue">Authors</font>
    </h3>
    <dl>
      <dd>
        <b></b>V.C.</dd>
    </dl>
  </body>
</html>
